$(document).ready(
    function(){
    var iNum1;
    var iNum2;
    var items = ['高校计算机等级考试','全国计算机等级考试','软考(专业技能考试)','英语','驾驶证','初级会计证','教师资格证','红十字救护证'];
    var levels =[["一级","二级","三级","四级"],["一级","二级","三级","四级"],["初级","中级","高级"],['四级','六级'],[""],[""],[""],[""]
    ];
    var points =[[[2],[4],[6],[8]],[[3],[5],[10],[15]],[[10],[15],[20]],[[10],[15]],[[5]],[[5]],[[10]],[[3]]];
    $(function(){
        // 1.页面加载初始化就已经填入默认值
        for(var i=0;i<items.length;i++){
            $('.selItems').append('<option>'+items[i]+'</option>');
        }
        iNum1 = $(".selItems option:selected").index();
        var default_uni = levels[iNum1];
        for(var s=0;s<default_uni.length;s++){
            $('.selLevels').append('<option>'+default_uni[s]+'</option>');
        }
        iNum2 = $(".selLevels option:selected").index();
        var default_mem = points[iNum1][iNum2];
        for(var g=0;g<default_mem.length;g++){
            $('.selPoints').append('<option>'+default_mem[g]+'</option>');
        }
    })
});
function add_bind_op(){
    var iNum1;
    var iNum2;
    var items= ['高校计算机等级考试','全国计算机等级考试','软考(专业技能考试)','英语','驾驶证','初级会计证','教师资格证','红十字救护证'];
    var levels =[["一级","二级","三级","四级"],["一级","二级","三级","四级"],["初级","中级","高级"],['四级','六级'],[""],[""],[""],[""]
    ];
    var points=[[[2],[4],[6],[8]],[[3],[5],[10],[15]],[[10],[15],[20]],[[10],[15]],[[5]],[[5]],[[10]],[[3]]];
    $(function(){
        // 1.页面加载初始化就已经填入默认值
        for(var i=0;i<items.length;i++){
            $('.selItems').last().append('<option>'+items[i]+'</option>');
        }
        iNum1 = $(".selItems option:selected").index();
        var default_uni = levels[iNum1];
        for(var s=0;s<default_uni.length;s++){
            $('.selLevels').last().append('<option>'+default_uni[s]+'</option>');
        }
        iNum2 = $(".selLevels option:selected").index();
        var default_mem = points[iNum1][iNum2];
        for(var g=0;g<default_mem.length;g++){
            $('.selPoints').last().append('<option>'+default_mem[g]+'</option>');
        }
        // 两个两个之间的绑定事件
        $(document).delegate('.selItems',"change",function () {

            $(this).parent('.form-group').children('.selLevels').children().remove();
            $(this).parent('.form-group').children('.selLevels').children('.selPoints').children().remove();
            iNum1 = $(this).children('option:selected').index();
            var alevels = levels[iNum1];
            for(var j=0;j<alevels.length;j++){
                $(this).parent('.mb-3').children('.selLevels').append('<option>'+alevels[j]+'</option>');
            }
            // $(this).next('select.selLevels').trigger("change");//三个联动的关键代码
            $(this).next().next('select.selLevels').trigger("change");//三个联动的关键代码
        });

        $(document).delegate('.selLevels',"change",function () {
            // $(this).next('select.selPoints').children().remove();
            $(this).next().next('select.selPoints').children().remove();
            iNum2 = $(this).children('option:selected').index();
            var apoints = points[iNum1][iNum2];
            for(var k=0;k<apoints.length;k++){
                // $(this).next('select.selPoints').append('<option>'+apoints[k]+'</option>');
                $(this).next().next('select.selPoints').append('<option>'+apoints[k]+'</option>');
            }
        })
    })
}